package day6.Component;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTable;

public class TestJTable extends JFrame {

	public TestJTable(String title) {
		this.setTitle(title);
		this.setSize(400, 500);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		initComponent();
		
		// 放到最后显示窗口
		this.setVisible(true);
	}
	// 初始化
	private void initComponent() {
		//table
		String[][] data = {
				{"1","tom","30"},
				{"2","tomi","60"},
				{"3","auther","90"}
				};
		String[] head = {"编号","姓名" , "分数"};
		JTable table = new JTable(data,head);
		//表头需要手头添加
		this.add(table.getTableHeader(),BorderLayout.NORTH);
		this.add(table);
		//表头 id 姓名 分数
		//数据 1 tom 30
		
	}

	public static void main(String[] args) {
		new TestJTable("表格");
	}
}




